<template>
  <div>
    <el-upload :action="UploadUrl" list-type="picture-card" :on-preview="handlePictureCardPreview"
      :on-remove="handleRemove" :on-success="handle">
      <i class="el-icon-plus"></i>
    </el-upload>
    <el-dialog :visible.sync="dialogVisible">
      <img width="100%" :src="dialogImageUrl" alt="">
    </el-dialog>
  </div>
</template>

<script>
import { UploadUrl } from '@/api/home';
  export default {
    name:'uploadIndex',
    data() {
      return {
        dialogImageUrl: '',
        dialogVisible: false,
        UploadUrl
      };
    },
    methods: {
      handleRemove(file, fileList) {
        console.log(file, fileList);
      },
      handlePictureCardPreview(file) {
        this.dialogImageUrl = file.url;
        this.dialogVisible = true;
      },
      // 上传成功
      handle(response){
        let url = response.url.slice(7)
        let imgUrl = 'https://8080'+'/'+url
        this.$emit('sendImg',imgUrl)
      }
    }
  }
</script>

<style>
</style>